sort
Type
command
Summary
Sorts the cards of a stack into a new order.
Syntax
sort [marked] cards [of <stack>] [<direction>] [<sortType>] by <sortKey>
Description
Use the sort command to shuffle the cards in a stack into a new order, or to shuffle a subset of the cards in a stack.
The sort command is a stable sort. This means that if the sortKey for two cards is the same, sorting does not change their order, so you can do two successive sorts to create subcategories within the major sort categories. For example, to sort the cards of a stack by ZIP code and sort within each ZIP code by last names, use these two statements:
sort cards by field \"Last Name\"
sort cards numeric by field \"ZIP code\"
The 'text' and 'international' forms are affected by the caseSensitive and formSensitive properties.
Parameters
Name | Type | Description |
---|---|---|
stack | A reference to any open stack. If you don't specify a stack, the cards of the current stack are sorted. | |
direction | enum | If you don't specify a direction, the sort is |
sortType | enum | If you don't specify a sortType, the sortType is |
sortKey | An expression that evaluates to a value for each card in the stack. Any object references within the sortKey are treated as pertaining to each card being evaluated, so for example, a reference to a field is evaluated according to that field's contents on each card. |
Examples
sort cards by field "name"
sort cards of this stack by random(the number of cards)
sort marked cards of stack "project1" numeric by the number of buttons
sort cards numeric by the short ID of this card
sort cards of stack "Manson" descending dateTime by item 1 of field "Date"
Related
command: find, sort container, filter
keyword: dateTime, numeric, text
property: mark
Compatibility and Support
Introduced
LiveCode 1.0
OS
mac
windows
linux
ios
android
Platforms
desktop
server
mobile